
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

    <title>Google Maps JavaScript API Example</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAnfhXv8naNMBHt3K2jNv9FhRf8_icm7gOmqyKW1v-cKTUNLlrYhQtc62JsAOzs_lYHd3CWzUjJv69vw"
      type="text/javascript"></script>
        



<script type="text/javascript">
    //<![CDATA[
 function load() {
        if (GBrowserIsCompatible()) {
      var px = 30.6562;
    var py = 104.0639;
    var zo = 12;
    var map = new GMap2(document.getElementById("map"));
    var point = new GLatLng(px, py);
    map.addControl(new GScaleControl());      //比例图示
    map.addControl(new GLargeMapControl()); //缩放图标
    map.addControl(new GOverviewMapControl());  
    map.enableDoubleClickZoom();//允许鼠标双击放大(左键)和缩小(右键)
    map.enableScrollWheelZoom();//允许鼠标滚轮放大和缩小
    map.enableContinuousZoom(); //
    map.setCenter(point, zo); 
  
    //点击获取地理坐标
    clickListener=GEvent.addListener(map, "click", function(marker,point)
     {
      if(point)
      {
       document.all.px.value=point.lat();
       document.all.py.value=point.lng();
      }
      if (marker) 
      {    
       map.removeOverlay(marker);  
      } else 
      {    
       map.clearOverlays();
       map.addOverlay(new GMarker(point));  
      }
     }
    ); 
  
// 获取当前倍率
    GEvent.addListener(map, "zoomend", function() {document.all.zo.value=map.getZoom();});
  
// 获取当前中心点  
    GEvent.addListener(map, "moveend", function() {var point = map.getCenter();document.all.mx.value=point.lat();document.all.my.value=point.lng();});
  
//初始化
    document.all.mx.value=px; 
    document.all.my.value=py;
    document.all.px.value=px;
    document.all.py.value=py;
    document.all.zo.value=zo;
     }
      }
      //]]>
      </script>


</script>
  </head>
  <body onload="load()" onunload="GUnload()">
          其中 (document.all.)mx、my、px、py 为四个文本框，分别表示：地图中心X、地图中心Y、点坐标X、点坐标Y、倍率，用于接收地图事件触发获取的相关数据。<br />
          mx<input name="mx" /><br />
          my<input name="my" /><br />
          px<input name="px" /><br />
          py<input name="py" /><br />
    <div id="map" style="width:500px;height:300px"></div>
  </body>

</html>


    
    
    
    